package com.tim.app.db.dao;

import android.content.Context;

import com.application.library.log.DLOG;
import com.tim.app.RT;


public class DaoFactory {

    private static String TAG = DaoFactory.class.getSimpleName();

    public enum DaoType {

       NOTICE_DAO
    }

    private static NoticeDao noticeDao = null;

    public static AbstractDAO createInstance(DaoType type) {
        Context ctx = RT.application.getApplicationContext();
        AbstractDAO dao = null;

        switch (type) {
            case NOTICE_DAO:
                if (noticeDao == null) {
                    synchronized (DaoFactory.class) {
                        if (noticeDao == null) {
                            noticeDao = new NoticeDao(ctx);
                        }
                    }
                }
                dao = noticeDao;
                break;
            default:
                DLOG.e(TAG, "the dao not exist!");

        }

        return dao;
    }

    public static NoticeDao getNoticeDao() {
        return (NoticeDao) createInstance(
                DaoType.NOTICE_DAO);
    }

    public static void clearDataAll(Context context) {
        GlobalHelperDao helperDao = (GlobalHelperDao) createInstance(DaoType.NOTICE_DAO);
        helperDao.clearAllTable();

    }
}
